Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chimee-helper-utils

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chimee-helper-utils

utils of chimee

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
decreased by-30%
Maintainers
2
Weekly downloads
 
Created
Source

chimee-helper-utils

Build Status Coverage Status npm dependency Status devDependency Status

utils of chimee

get started

npm install chimee-helper-utils --save

if you are using flow, you should import our flow defination, by adding this to your .flowconfig.

[ignore]

[include]

[libs]
./node_modules/chimee-helper-utils/lib/index.flow.js
[options]

[lints]

doc

inBrowser

src/index.js:8-10

check if the code running in browser environment (not include worker env)

Returns Boolean

makeArray

src/index.js:16-18

转变一个类数组对象为数组

Parameters

  • obj any

Returns Array<any>

transObjectAttrIntoArray

src/index.js:27-33

sort Object attributes by function and transfer them into array

Parameters

  • obj Object Object form from numric
  • fn Function sort function (optional, default (a,b)=>+a-+b)

Returns Array the sorted attirbutes array

runRejectableQueue

src/index.js:39-56

run a queue one by one.If include function reject or return false it will stop

Parameters

  • queue Array the queue which we want to run one by one
  • args ...any

Returns Promise tell us whether a queue run finished

runStoppableQueue

src/index.js:62-74

run a queue one by one.If include function return false it will stop

Parameters

  • queue Array the queue which we want to run one by one
  • args ...any

Returns boolean tell the user if the queue run finished

setFrozenAttr

src/index.js:82-91

set an attribute to an object which is frozen. Means you can't remove it, iterate it or rewrite it.

Parameters

  • obj !primitive
  • key string
  • value Anything

setAttrGetterAndSetter

src/index.js:100-120

set attr on an Object. We will bind getter and setter on it if you provide to us

Parameters

  • obj !primitive
  • key string
  • $2 any (optional, default {})
    • $2.get
    • $2.set
  • prefix String the origin data's prefix. We do not plan to save it by closure. (optional, default '__')
  • get Function
  • set Function

throttle

src/index.js:232-280

函数节流(控制函数执行频率)

Parameters

  • func Function 要节流控制的函数,必填
  • wait number
  • options any
  • cxt any

Returns Number wait 等待时长

Returns Object options { leading<是否首次调用立即执行,否:则按wait设定等待到期后调用才执行>:false, trailing<是否在调用并未到期时启用定时器,以保证一定执行>:true }

Returns Object cxt 上下文对象

Returns Function

addTransMethod

src/index.js:323-336

给obj对象扩展上trans方法,用以实现methodName对应的属性方法包装为静态函数且保持上下文的功能

Parameters

appendCSS

src/index.js:343-353

追加样式代码到head的style标签,不存在则创建

Parameters

Returns HTMLElement

formatDate

src/index.js:361-379

格式化日期对象为:年-月-日 时:分:秒.毫秒

Parameters

  • date Date Date日期对象 (optional, default new Date())
  • pattern String 要输出的日期格式,默认:yyyy-MM-dd hh:mm:ss.i (optional, default 'yyyy-MM-dd hh:mm:ss.i')

Returns String

getLocalStorage

src/index.js:386-397

读取本地存储的值(不支持localStorage则降级到cookie)

Parameters

Returns String

setLocalStorage

src/index.js:404-415

将指定key对应值写入本地存储(不支持localStorage则降级到cookie)

Parameters

Returns String

Keywords

FAQs

Package last updated on 07 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc